package com.example.config;

import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
        // 自定义配置
//        FastJsonConfig config = new FastJsonConfig();
//        config.setSerializeFilters();
//        fastJsonHttpMessageConverter.setFastJsonConfig(config);
//        converters.add(0, fastJsonHttpMessageConverter);
        converters.add(fastJsonHttpMessageConverter);
    }
}
